<!DOCTYPE html>
<html>
<head>
<title>用户卡片管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../../include/resources.html">
<script type="text/javascript">
	var dataGrid;
	var winWidth =  500; //弹出窗口宽度
	var winHeight = 300; //弹出窗口高度
	//标记卡片为无效
	var failureTitle = "确定将该用户卡片置为无效？";
	var failureUrl = "/modules/additional/card/userCard/updateUserCardInvalid.html";
	//发放卡片
	var addTitle = "发放卡片"; //添加窗口标题
	var addUrl =  "/modules/additional/card/userCard/append.html"; // 添加窗口链接地址

	$(function() {
		dataGrid = $('#dataGrid').datagrid({
			url : 'userCardList.html',
			fit : true,
			fitColumns : true,
            border : false,
            pagination : true,
            idField : 'id',
            pageSize : pageSize,
            pageNums :1,
            pageList : pageList,
            sortName : 'id',
            sortOrder : 'asc',
            checkOnSelect : false,
            selectOnCheck : false,
            nowrap : false,
			singleSelect:true,
			frozenColumns:[[
							{ field: 'id', title: '编号', width: 50, checkbox : false},
							{ field: 'userName', title: '用户名', width: 140, sortable:false },
							{ field: 'name', title: '卡片名称', width: 140, sortable:false,},
							{ field: 'typeStr', title: '卡片类型', width: 80, fixed:true,sortable:false },
						]],
			columns : [ [ 		
			{ field: 'statusStr', title: '状态', width: 80, sortable:false},
			{ field: 'validDay', title: '有效天数', width: 80, sortable:false},
			{ field: 'expiredTime', title: '过期时间', width: 140, sortable:false,formatter: function(value,row,index){
				  return getLocalTime(value,4);
			  }
			},
			{ field: 'useTime', title: '使用时间',width: 140, sortable:false,formatter: function(value,row,index){
	          	  return getLocalTime(value,4);
				  }   
			 },
			 { field: 'addTime', title: '获取时间',width: 140, sortable:false,formatter: function(value,row,index){
	          	  return getLocalTime(value,4);
				  }   
			 },
			 { field: 'sourceType', title: '卡片来源', width: 120, sortable:false},
			 { field: 'useTypeStr', title: '使用类型', width: 120, sortable:false},
			  {	field : 'action',
				title : '操作',
				width :100,
				formatter : function(value, row, index) {
					var str = '';
					str += '<dl>';
					if(row.status == 0)
					str += '<dt><a href="javascript:void(0);" onclick="$.fn.dataGridOptions.deleteFun('+row.id+',failureUrl,failureTitle);">置为无效</a></dt>' ;
					str += '<dd>';
					str +=  '</dl>'
					return str;
				}
			} ] ],
			toolbar : '#toolbar',
			
		});
	});
	
	function exportExcel(){
		var url = "/modules/additional/card/userCard/exportUserCardToExcel.html";
		var userName = $("#userName").val();
		var name = $("#name").val();
		var status = $("#status").val();
		var startTime = $("#startTime").val();
		var endTime = $("#endTime").val();
		var useStartTime = $("#useStartTime").val();
		var useEndTime = $("#useEndTime").val();
		var sou = "?userName=" + userName + "&status=" + status + "&startTime=" + startTime + "&endTime=" + endTime 
					+ "&useStartTime=" + useStartTime + "&useEndTime=" + useEndTime+"&name="+name;
		window.location.href = url + sou;
	}
</script>
</head>
<body style="padding:0 20px;" >
	<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'north',border:false,collapsible:false" id="searchBox">
			<div class="sLeft">
	            <form id="searchForm">
	            	<input type="text"  name="searchName" id="searchName" class="sInput" placeholder="输入用户名进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a><a href="javascript:;" class="advBtn" title="条件查询">条件查询 <i class="iconfont">&#xe638;</i></a>
	            	 <a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
	            </form>
            </div>
            <form id="showAdw">
		        <ul class="showAdw" style="display:none;">
		        	<a href="javascript:void(0);"><i class="iconfont closeWin">&#xe63a;</i></a>
		        	<li><span>用户名</span><input type="text" name="userName" id="userName" autocomplete="off"/></li>
		        	<li><span>卡片名称</span><input type="text" name="name"  id="name" autocomplete="off"/></li>
		        	<li><span>卡片状态</span><select name="status" id="status" class="status">
							<option value=99>全部</option>
							<option value="1">已使用</option>
							<option value="0">未使用</option>
							<option value="2">已过期</option>
							<option value="3">无效</option>
						</select></li>
					<li><span>获取时间</span><input type="text" name="startTime" id="startTime" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" class="searchTime"/>&nbsp;-&nbsp;<input type="text" name="endTime" id="endTime" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" class="searchTime"/></li>
					<li><span>使用时间</span><input type="text" name="useStartTime" id="useStartTime" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" class="searchTime"/>&nbsp;-&nbsp;<input type="text" name="useEndTime" id="useEndTime" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" class="searchTime"/></li>
		       		<li><span></span><a href="javascript:void(0);" class="searchBtn sureBtn" onclick="$.fn.dataGridOptions.searchFun('#showAdw');">确定</a><a href="javascript:void(0);" class="searchBtn" onclick="$.fn.dataGridOptions.cleanFun('#searchForm');">重置</a></li>
		        </ul>
	        </form>
            <div class="sRight">
            	<a id="a" onclick="exportExcel();" href="javascript:void(0);" class="addBtn">导出excel</a>
				<a onclick="$.fn.dataGridOptions.addFun(-1,addTitle,winWidth,winHeight,addUrl);" href="javascript:void(0);" class="addBtn"><i class="iconfont">&#xe629;</i>发放卡片</a>
			</div>
		</div>
		<div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
			<table id="dataGrid"></table>
		</div>
	</div>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>